#ifndef __IM_ADDRESS_UNIX_H__
#define __IM_ADDRESS_UNIX_H__

#include <im_object.h>
#include <im_address.h>

/**
 * @defgroup IMAddressUnix
 * @ingroup PrivateIMBus
 * @{
 */

/** @struct IMAddressUnix
 *  @brief Unix implementation of IMAddress interface.
 *
 * IMAddressUnix encapsulates the details of
 * socket address, like socketaddr_un and socketaddr_in.
 *
 * A SocketAddress object can be constructed from an
 * address string, which must start with one of the
 * following prefixes:
 *  - inet: or tcp:
 *    A internet address (ipv4). This kind of address must
 *    include two parts, separated by a colon. The first part
 *    is the ip address, the second part is the port. For example:
 *    inet:127.0.0.1:12345
 *  - local: or unix: or file:
 *    A unix or local socket address. It's a full path of a socket file.
 *    For example: local:/tmp/imbus-daemon-xxx
 */

IM_BEGIN_DECLS

#define IM_ADDRESS_UNIX(p)             (IM_TYPE_INSTANCE_CHECK_CAST((p),IM_TYPE_ADDRESS_UNIX,IMAddressUnix))
#define IM_CONST_ADDRESS_UNIX(p)       (IM_TYPE_INSTANCE_CHECK_CAST_CONST((p),IM_TYPE_ADDRESS_UNIX,IMAddressUnix))
#define IM_ADDRESS_UNIX_CLASS(c)       (IM_TYPE_CLASS_CHECK_CAST((c),IM_TYPE_ADDRESS_UNIX,IMAddressUnixClass))
#define IM_IS_ADDRESS_UNIX(p)          (IM_TYPE_INSTANCE_CHECK_TYPE((p),IM_TYPE_ADDRESS_UNIX))
#define IM_IS_ADDRESS_UNIX_CLASS(c)    (IM_TYPE_CLASS_CHECK_TYPE((c),IM_TYPE_ADDRESS_UNIX))
#define IM_ADDRESS_UNIX_GET_CLASS(p)   (IM_TYPE_INSTANCE_GET_CLASS_CAST((p),IM_TYPE_ADDRESS_UNIX,IMAddressUnixClass))

typedef struct _IMAddressUnix                    IMAddressUnix;
typedef struct _IMAddressUnixClass               IMAddressUnixClass;

typedef enum {
  IM_ADDRESS_UNIX_INVALID = 0,
  IM_ADDRESS_UNIX_LOCAL,
  IM_ADDRESS_UNIX_INET
} IMAddressUnixType;

/**
 * @brief Create a new IMAddressUnix object from an address string.
 *
 * The newly created IMAddressUnix object is a floating object, creator
 * should call im_object_ref() to assume its ownership.
 */
IMAddress*  im_address_unix_new                 (const char             *addr_string);

IMAddressUnixType im_address_unix_get_type      (const IMAddressUnix    *address);
IMConstPointer im_address_unix_get_data         (const IMAddressUnix    *address);
IMSize      im_address_unix_get_data_length     (const IMAddressUnix    *address);

IMBool      im_address_unix_remove_related_file (const IMAddressUnix    *address);
IMBool      im_address_unix_secure_related_file (const IMAddressUnix    *address);

IM_END_DECLS
/** @} */

#endif
/*
vi:ts=4:nowrap:ai:expandtab
*/
